<?php if(!defined('BASEPATH')) exit("Sorry, what you're looking not found.");
class C_ubahpass extends Nvl_Controller{
    function __construct(){
        parent::__construct();
        session_start();
		$this->__checkSession();
    }

    function index(){
        $this->load->view('pages/v_ubahpass');
    }

	function ubahpass(){
		$user_id = $_SESSION[SESSION_USERID];
		$params = json_decode($this->input->post('params'));
		extract(get_object_vars($params));
		extract(get_object_vars($form_data));
		if($pass_baru != $pass_baru2){
			echo 'password_beda';
		}else{
			$result = $this->db->where('user_name', $user_id)->limit(1)->get('m_user')->row();
			if($result->user_password == $pass_lama){
				$this->db->where('user_name', $user_id)->update('m_user', array('user_password'=> $pass_baru));
				echo 'sukses';
			}else{
				echo 'password_salah';
			}
		}
	}
}